scrolledwindow: Fix swapping out child
authorMatthias Clasen <mclasen@redhat.com>
Wed, 13 May 2020 21:10:36 +0000 (17:10 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 13 May 2020 21:10:36 +0000 (17:10 -0400)
This was not working in the case that the existing child
is not a scrollable. It showed up as crashes of the
scrolling benchmark in gtk4-demo when switching examples.

gtk/gtkscrolledwindow.c

index f2b8493234c597582b89e7e7e151e41a2eb0e7cb..f1b23d87eb44b36fede8133ba0e4ca6fe048d12b 100644 (file)
@@ -4166,20 +4166,16 @@ gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
 
   if (priv->child)
     {
-      if (!priv->auto_added_viewport)
+      if (priv->auto_added_viewport)
         {
-          scrollable_child = priv->child;
-        }
-      else
-        {
-          scrollable_child = gtk_viewport_get_child (GTK_VIEWPORT (priv->child));
           gtk_viewport_set_child (GTK_VIEWPORT (priv->child), NULL);
         }
 
-      g_object_set (scrollable_child,
+      g_object_set (priv->child,
                     "hadjustment", NULL,
                     "vadjustment", NULL,
                     NULL);
+
       g_clear_pointer (&priv->child, gtk_widget_unparent);
     }